Skip to content

test: add unit tests for core helpers and wire tests into CI - #127

Merged
antfu merged 1 commit into
mainfrom
grumpy-laws-cross
Aug 3, 2026
Merged

test: add unit tests for core helpers and wire tests into CI#127
antfu merged 1 commit into
mainfrom
grumpy-laws-cross

Conversation

@antfubot

@antfubot antfubot commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

What

Introduces a baseline of unit tests for the library's pure, dependency-free helpers, plus one mocked-network test, and makes CI actually run the test suite.

Tests added (46 assertions across 6 files)

  • normalizeUrl — protocol defaulting and normalization
  • guessProviders / resolveProviders / ProvidersMap — provider detection, dedupe, and unknown-name errors
  • partitionTiers — tier bucketing, the "exactly one zero-dollar tier" invariant, past-sponsor filtering, and within-tier ordering
  • makeQuery / makeSponsoringQuery / makeSponsoringTotalAmountQuery — GraphQL string builders
  • fetchGitHubSponsors — argument validation, pagination, response mapping, and error handling (via a mocked ofetch)
  • SvgComposer and genSvgImage — SVG assembly and deterministic clip ids

Tooling

  • Add vitest.config.ts excluding the example/ workspace from the run
  • test script now runs vitest run (non-watch) so it terminates in CI; add test:watch for local watch mode
  • Replace lint.yml with ci.yml using the shared sxzz/workflows unit-test workflow, which runs lint + build + typecheck + test (superseding the old lint-only workflow)

Why

The repo had a single existing test file and CI never ran tests. This establishes a fast, mock-light safety net over the most testable logic and ensures tests gate PRs.

This PR was created with the help of an agent.

Cover normalizeUrl, provider guessing/resolution, tier partitioning,
GitHub GraphQL query builders, the GitHub sponsors fetcher, and the SVG
composer. Run tests in CI via the shared sxzz workflow and switch the
default test script to non-watch mode.
@antfubot
antfubot force-pushed the grumpy-laws-cross branch from 513eda5 to e2dd178 Compare August 3, 2026 00:32
@antfu
antfu merged commit 329b55a into main Aug 3, 2026
7 checks passed
@antfu
antfu deleted the grumpy-laws-cross branch August 3, 2026 00:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants